package times

import (
	"fmt"
	"math"
	"time"
)

func GetNowTime() (int64, error) {
	local := time.Now().Unix()
	netTime, err := GetSuningTimestamp()
	if err != nil {
		netTime, err = GetNetworkUnixTime("Asia/Shanghai")
		if err != nil {
			return 0, err
		}
	}

	if math.Abs(float64(local-netTime)) > 600 {
		return 0, fmt.Errorf("时间差太大%d", local-netTime)
	}
	return local, nil
}
